//
//  TestViewController.m
//  GolfFriend
//
//  Created by Vescky on 13-12-4.
//  Copyright (c) 2013年 vescky.org. All rights reserved.
//

#import "TestViewController.h"
#import "LitePhotoCollectionView.h"
#import "UMSocial.h"
#import "UMSocialWechatHandler.h"
#import "SVProgressHUD.h"

@interface TestViewController ()<UMSocialUIDelegate> {
    LitePhotoCollectionView *lImgView;
}

@end

@implementation TestViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    
    
//    [[UMSocialData defaultData].urlResource setResourceType:UMSocialUrlResourceTypeImage url:@"http://www.baidu.com"];
//    [UMSocialData defaultData].extConfig.wechatSessionData.url = @"http://www.baidu.com";
    
    // Do any additional setup after loading the view from its nib.
    
//    NSMutableArray *imgs = [[NSMutableArray alloc] initWithObjects:@"http://ww4.sinaimg.cn/thumbnail/7f8c1087gw1e9g06pc68ug20ag05y4qq.gif", @"http://ww3.sinaimg.cn/thumbnail/8e88b0c1gw1e9lpr0nly5j20pf0gygo6.jpg", @"http://ww4.sinaimg.cn/thumbnail/8e88b0c1gw1e9lpr1d0vyj20pf0gytcj.jpg", @"http://ww3.sinaimg.cn/thumbnail/8e88b0c1gw1e9lpr1xydcj20gy0o9q6s.jpg", @"http://ww2.sinaimg.cn/thumbnail/8e88b0c1gw1e9lpr2n1jjj20gy0o9tcc.jpg", @"http://ww2.sinaimg.cn/thumbnail/8e88b0c1gw1e9lpr39ht9j20gy0o6q74.jpg", @"http://ww3.sinaimg.cn/thumbnail/8e88b0c1gw1e9lpr3xvtlj20gy0obadv.jpg", @"http://ww4.sinaimg.cn/thumbnail/8e88b0c1gw1e9lpr4nndfj20gy0o9q6i.jpg", @"http://ww3.sinaimg.cn/thumbnail/8e88b0c1gw1e9lpr57tn9j20gy0obn0f.jpg", nil];
//    lImgView = [[LitePhotoCollectionView alloc] init];
//    [lImgView setPhotoCollection:imgs];
//    [lImgView setMargin:10.0];
//    [lImgView setViewWidth:280.0];
//    [lImgView setColCount:3];
//    [self.view addSubview:lImgView.view];
//    
//    NSString *imgPath = [[[NSBundle mainBundle] bundlePath] stringByAppendingPathComponent:@"hp_session1_bg.png"];
//    [[ImageUploader shareImageUploader] uploadImage:imgPath asName:@"test11.png"];
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


- (IBAction)btnAction:(id)sender {
    [UMSocialData defaultData].extConfig.wechatSessionData.title = @"名媛荟分享";
    [UMSocialWechatHandler setWXAppId:Wechat_Key url:@"http://wap.baidu.com"];
    [UMSocialSnsService presentSnsIconSheetView:self
                                         appKey:UMSocial_Key
                                      shareText:@"只是测试一下.."
                                     shareImage:[UIImage imageNamed:@"hp_session1_bg.png"]
                                shareToSnsNames:[NSArray arrayWithObjects:UMShareToSina,UMShareToWechatTimeline,UMShareToWechatSession,UMShareToEmail,nil]
                                       delegate:self];
}

-(void)didFinishGetUMSocialDataInViewController:(UMSocialResponseEntity *)response
{
    //根据`responseCode`得到发送结果,如果分享成功
    if(response.responseCode == UMSResponseCodeSuccess)
    {
        //得到分享到的微博平台名
//        NSLog(@"share to sns name is %@",[[response.data allKeys] objectAtIndex:0]);
        [SVProgressHUD showSuccessWithStatus:[NSString stringWithFormat:@"分享到%@成功!",[[response.data allKeys] objectAtIndex:0]]];
    }
    else if (response.responseCode == UMSResponseCodeBaned) {
        [SVProgressHUD showErrorWithStatus:@"分享失败，您的账户已被封禁！"];
    }
    else if (response.responseCode == UMSResponseCodeShareRepeated) {
        [SVProgressHUD showErrorWithStatus:@"分享失败：发送内容为空！"];
    }
    else if (response.responseCode == UMSResponseCodeGetNoUidFromOauth) {
        [SVProgressHUD showErrorWithStatus:@"分享失败：分享内容重复！"];
    }
    else {
        [SVProgressHUD showErrorWithStatus:@"分享失败"];
    }
    
    NSLog(@"%d",response.responseCode);
    
//    UMSResponseCodeBaned              = 505,        //用户被封禁
//    UMSResponseCodeFaild              = 510,        //发送失败（由于内容不符合要求或者其他原因）
//    UMSResponseCodeEmptyContent       = 5007,       //发送内容为空
//    UMSResponseCodeShareRepeated      = 5016,       //分享内容重复
//    UMSResponseCodeGetNoUidFromOauth  = 5020,       //授权之后没有得到用户uid
//    UMSResponseCodeAccessTokenExpired = 5027,       //token过期
//    UMSResponseCodeNetworkError       = 5050,       //网络错误
//    UMSResponseCodeGetProfileFailed   = 5051,       //获取账户失败
//    UMSResponseCodeCancel             = 5052,        //用户取消授权
//    UMSResponseCodeNoApiAuthority
}

@end
